<template>
	<view class="standardContainer">
		<view class="navBarContainer">
			<view class="navBar">
				<view class="back" @click="goBack">
					<view class="iconContainer">
						<u-icon name="arrow-left" size="20"></u-icon>
					</view>
				</view>
				<text class="title">{{allInfo.name}}</text>
				<view class="other">
					
				</view>
			</view>
		</view>
		<view class="foodContainer">
			<view class="foodImg" :style="[{backgroundImage:'url('+allInfo.image+')'}]">
				
			</view>
			<view class="title">
				{{allInfo.name}}
			</view>
			<view class="detail">
				{{allInfo.description}}
			</view>
			<view class="selectFoodContainer">
				<view class="food" v-for="(food,index) in allInfo.dishItemVOList" :key="index"
					:style="[(index+1)%3==0?{}:{marginRight:'20rpx'}]"
				>
					<view class="img" :style="[{backgroundImage:'url('+food.image+')'}]">
						
					</view>
					<view class="name">
						{{food.name}}
					</view>
					<view class="des">
						{{food.description}}
					</view>
					<view class="copies">
						份数: {{food.copies}}份
					</view>
				</view>
			</view>
		</view>
		<view class="tabContainer">
			<view class="price">
				￥{{allInfo.price}}
			</view>
			<view class="pay" @click="goPay">
				购买
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				setmealId:'',
				allInfo:[]
			}
		},
		methods: {
			goBack(){
				uni.navigateBack()
			},
			goPay(){
				uni.request({
					url:`http://localhost:8080/kfc/user/shoppingCart/add?setmealId=${this.setmealId}`,
					method:'post',
					header:{
						token:uni.getStorageSync('STATE_KEY').token
					},
					success:(res)=>{
						console.log('购物车增加套餐',res.data)
						uni.navigateTo({
							url:`./orderMeal?setmealId=${this.setmealId}`
						})
					}
				})
			}
		},
		mounted(){
			uni.request({
				url:`http://localhost:8080/kfc/user/setmeal/dish?id=${this.setmealId}`,
				header:{
					token:uni.getStorageSync('STATE_KEY').token
				},
				method:'get',
				success:(res)=>{
					this.allInfo=res.data.data
					console.log('套餐信息',res.data.data)
				}
			})
		},
		onLoad:function(options){
			this.setmealId=options.id
			console.log('套餐id',options.id)
		}
	}
</script>

<style lang="scss" scoped>
	.standardContainer{
		width: 100vw;
		.navBarContainer{
			width: 100vw;
			height: 200rpx;
			position: fixed;
			z-index: 99;
			top:0rpx;
			left: 0;
			background-color: #FFF;
			display: flex;
			align-items: center;
			justify-content: center;
			// margin-top: 30rpx;
			.navBar{
				width: 90%;
				margin: 0 auto;
				margin-top: 100rpx;
				background-color: #FFF;
				display: flex;
				align-items: center;
				justify-content: space-between;
				.back,.other{
					width: 70rpx;
				}
				.title{
					font-size: 30rpx;
				}
			}
		}
		.foodContainer{
			margin-top: 200rpx;
			width: 100%;
			display: flex;
			flex-direction: column;
			.foodImg{
				width: 100%;
				// background-color: aliceblue;
				height: 600rpx;
				background-position: center;
				background-size: cover;
				background-repeat: no-repeat;
			}
			>.title{
				font-size: 36rpx;
				font-weight: bold;
				margin-top: 15rpx;
				margin-left: 15rpx;
			}
			.detail{
				margin-left: 15rpx;
				color: #999999;
				font-size: 24rpx;
				margin-top: 10rpx;
			}
			.selectFoodContainer{
				margin: 0 auto;
				margin-top: 50rpx;
				width: 710rpx;
				>.food{
					float: left;
					width: 220rpx;
					height: 320rpx;
					background-color: #FFF;
					border: 1px solid rgb(228,0,48);
					border-radius: 20rpx;
					display: flex;
					flex-direction: column;
					.img{
						// background-color: aliceblue;
						border-top-left-radius: 20rpx;
						border-top-right-radius: 20rpx;
						width: 100%;
						height: 160rpx;
						background-size: cover;
						background-position: center;
						background-repeat: no-repeat;
					}
					.name{
						margin-top: 10rpx;
						font-size: 30rpx;
					}
					.des,.copies{
						color:#999999;
						font-size: 24rpx;
						margin-top: 10rpx;
					}
				}
			}
		}
		.tabContainer{
			width: 710rpx;
			position: fixed;
			left: 20rpx;
			bottom: 50rpx;
			background-color: #FFF;
			border-radius: 20rpx;
			border: 1px solid rgb(228,0,48);
			color:rgb(228,0,48);
			display: flex;
			align-items: center;
			justify-content: space-between;
			z-index: 99;
			font-size: 34rpx;
			.price{
				margin-left: 25rpx;
				margin-top: 20rpx;
				margin-bottom: 20rpx;
			}
			.pay{
				margin-right: 25rpx;
			}
		}
	}
</style>
